package com.iknow.ui.model;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.iknow.data.QingBo;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class FavoriteQingboAdapter extends BaseAdapter
{
  private static final String TAG = "FavoriteQingboAdapter";
  private LayoutInflater mLayoutInflater;
  private List<QingBo> mQingBoList;
  private int txtColor = -16777216;

  public FavoriteQingboAdapter(Context paramContext, LayoutInflater paramLayoutInflater)
  {
    this.mLayoutInflater = paramLayoutInflater;
    this.mQingBoList = new ArrayList();
  }

  private void fillDataToView(QingBo paramQingBo, View paramView)
  {
    ((QingBoViewHolder)paramView.getTag()).Title.setText(paramQingBo.getTitle());
  }

  private View newView(QingBo paramQingBo)
  {
    View localView = this.mLayoutInflater.inflate(2130903091, null);
    QingBoViewHolder localQingBoViewHolder = new QingBoViewHolder(this, null);
    localQingBoViewHolder.Title = ((TextView)localView.findViewById(2131296437));
    localQingBoViewHolder.Title.setTextColor(getTxtColor());
    localView.setTag(localQingBoViewHolder);
    return localView;
  }

  public void addQingboAtFoot(List<QingBo> paramList)
  {
    this.mQingBoList.addAll(paramList);
  }

  public void addQingboAtHead(List<QingBo> paramList)
  {
    if (paramList != null)
      this.mQingBoList.addAll(0, paramList);
  }

  public void clearQingBo(int paramInt)
  {
    this.mQingBoList.remove(paramInt);
  }

  public void clearQingboList(int paramInt1, int paramInt2)
  {
    if (paramInt1 < 0)
      return;
    if (paramInt2 > this.mQingBoList.size())
      paramInt2 = this.mQingBoList.size();
    Iterator localIterator = this.mQingBoList.iterator();
    while (true)
    {
      if ((!(localIterator.hasNext())) || (paramInt1 > paramInt2));
      localIterator.next();
      localIterator.remove();
      ++paramInt1;
    }
  }

  public int getCount()
  {
    return this.mQingBoList.size();
  }

  public QingBo getItem(int paramInt)
  {
    return ((QingBo)this.mQingBoList.get(paramInt));
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public int getTxtColor()
  {
    return this.txtColor;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    View localView;
    QingBo localQingBo = getItem(paramInt);
    if (localQingBo == null)
      localView = null;
    while (true)
    {
      return localView;
      if (paramView == null)
        paramView = newView(localQingBo);
      fillDataToView(localQingBo, paramView);
      localView = paramView;
    }
  }

  public void resetTextColor(int paramInt)
  {
    this.txtColor = paramInt;
  }

  public void setQingBoList(List<QingBo> paramList)
  {
    this.mQingBoList = paramList;
  }

  private class QingBoViewHolder
  {
    public TextView Title;
  }
}